// @Author miaoqing
// @Date 2024/03/01 18:19:00
// @Desc
package logic

import "core/command"

func (mgr *OnlineClientMgr) publishMsgToOtherClient(msg *command.OnlineMsgToCenter) {
	val, ok := mgr.topicChanelClient.Load(msg.Topic)
	if !ok {
		return
	}
	del := make([]string, 0)
	m := val.(map[string]int)
	if len(m) == 0 {
		return
	}
	msgSend := &command.CenterMsgToOnline{
		PlayerID: msg.PlayerID,
		Data:     msg.Data,
	}
	for serverID := range m {
		if !mgr.sendMsgToOnline(serverID, msgSend) {
			del = append(del, serverID)
		}
	}
	if len(del) != 0 {
		for _, id := range del {
			delete(m, id)
		}
		mgr.topicChanelClient.Store(msg.Topic, m)
	}
}
